import Vue from 'vue'
import { Notification } from 'element-ui'

const NotificationService = {
  show(options) {
    // 播放提醒音效
    if (options.playSound) {
      const audio = new Audio('/notification.mp3')
      audio.play().catch(error => console.log('Error playing notification sound:', error))
    }

    // 使用 Element UI 的 Notification 组件
    Notification({
      title: options.title || '提醒',
      message: options.message,
      type: options.type || 'info',
      position: 'bottom-right',
      duration: 0, // 设置为0表示不会自动关闭
      showClose: true,
      customClass: 'custom-notification'
    })
  }
}

// 添加全局样式
const style = document.createElement('style')
style.textContent = `
  .custom-notification .el-notification__title {
    text-align: left !important;
  }
  .custom-notification .el-notification__content {
    text-align: left !important;
  }
  .custom-notification.el-notification--warning .el-notification__icon {
    color: #F56C6C !important;
  }
`
document.head.appendChild(style)

export default NotificationService 